<?php
include_once("functions/db_manipulate.php");

if (!init()) {
    redirect("login.php");
}

$galleryResultSet = getLastGalleryImages();

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Галерея - theFlyNet.com</title>

    <link rel="stylesheet" type="text/css" href="css/square.css">
    <link rel="stylesheet" type="text/css" href="css/menu.css">
    <link rel="stylesheet" type="text/css" href="css/common.css">
    <link rel="stylesheet" type="text/css" href="css/gallery.css">
    <link rel="stylesheet" type="text/css" href="css/profile.css">
    <link rel="stylesheet" type="text/css" href="css/navigation.css">
    <script src="resources/jquery.js"></script>
    <script language="JavaScript">
        function customFormSubmit() {
            $('#maximized_navigation').show();
            $('#galimgform').submit();
        }
    </script>

    <meta charset="UTF-8">
</head>

<body class="body">

<?php
include_once("menu.php");
?>

<div id="square">

    <div class="gallerydiv">
        <div class="galleryheader">
            Последние изображения:
        </div>
        <?php
        while ($gallery = mysql_fetch_assoc($galleryResultSet)) {
            ?>
            <div class="galleryimgdiv" onclick="location.href='image.php?iid=<?= $gallery['id'] ?>'">
                <div class="imageinfo">
                    <div class="imageinfotd">
                        #<?= $gallery['id'] ?>
                    </div>
                    <div class="imageinfotd" style="text-align: right;">
                        <?= $gallery['time'] ?>
                    </div>

                </div>
                <img src="gallery/<?= $gallery['path'] ?>" class="galleryimg">

                <div class="imageauthorinfo">
                    <div class="imageinfotd">
                        <?= getTextWithAcronym($gallery['author'], 10) ?>
                    </div>
                    <div class="imageinfotd" style="text-align: right;">
                        <?= $gallery['date'] ?>
                    </div>

                </div>
            </div>

        <?php
        }
        ?>

        <div class="archivebutton" onclick="location.href='gallery_archive.php'">
            Архив изображений
        </div>

        <form enctype="multipart/form-data" style="width: 70%; margin-left: auto; margin-right: auto"
              accept-charset="UTF-8" action="profile/galimg_handler.php" method="post"
              id="galimgform">
            <span style="font-weight: bold">Новый комментарий:</span>
            <textarea name="header" id="textarea" rows="1" placeholder="News header.." required="true"></textarea>
            <textarea name="legend" id="textarea" rows="11" placeholder="Type your legend here.."></textarea>

            <input type="hidden" name="MAX_FILE_SIZE" value="25000000"/>

            <div style="display: inline-block; width: 100%">
                <div id="fileinputdiv">
                    <input name="image" required="true" type="file" accept=".jpg, .png, .jpeg, .gif" id="realfileinput"
                           onclick="$('#galvisdiv').slideDown()">

                    <div id="fileinput">Изображения</div>

                </div>


                <div id="commentbutton" onclick="customFormSubmit()">
                    Продолжить
                </div>
                <div id="galvisdiv">
                    Отображать изображение другим пользователям:
                    <select class="updateuserinfoinput" name="galvis">
                        <option selected value="true">
                            Да
                        </option>
                        <option value="false">
                            Нет
                        </option>
                    </select>
                </div>

            </div>
        </form>
    </div>

</div>

<?php
include_once("navigation.html");
?>

</body>
</html>
